(function(){"use strict";BX.namespace("BX.UI");BX.UI.ActionPanel.Item=function(t){this.id=t.id;this.type=t.type;this.text=t.text;this.html=t.text;this.icon=t.icon;this.title=t.title;this.iconOnly=t.iconOnly;this.additionalClassForPanel=t.additionalClassForPanel;this.submenuOptions={};if(t.submenuOptions&&BX.type.isString(t.submenuOptions)){try{this.submenuOptions=JSON.parse(t.submenuOptions)}catch(t){}}this.buttonIconClass=t.buttonIconClass;this.onclick=t.onclick;this.href=t.href;this.items=t.items;this.actionPanel=t.actionPanel;this.options=t;this.attributes=BX.prop.getObject(t,"attributes");this.dataset=t.dataset;this.disabled=t.disabled;this.layout={container:null,icon:null,text:null}};BX.UI.ActionPanel.Item.prototype={changeIconClass:function(t){BX.removeClass(this.layout.container,this.buttonIconClass);BX.addClass(this.layout.container,t);this.buttonIconClass=t},render:function(){var t;this.href?t="a":t="div";var i="ui-action-panel-item "+(this.additionalClassForPanel?this.additionalClassForPanel+" ":"")+(this.disabled?"ui-action-panel-item-is-disabled":"");if(this.buttonIconClass){i="ui-btn ui-btn-lg ui-btn-link "+this.buttonIconClass}if(this.onclick&&BX.type.isArray(this.items)&&this.items.length>0){this.layout.container=BX.create("div",{props:{className:"ui-btn-split ui-btn-link"+(this.buttonIconClass||"")},children:[BX.create("button",{props:{className:"ui-btn-main"},events:{click:this.handleMainClick.bind(this)},text:this.text}),BX.create("button",{props:{className:"ui-btn-menu"},events:{click:this.handleMenuClick.bind(this)}})],attrs:this.attributes,dataset:{role:"action-panel-item"}})}else{this.layout.container=BX.create(t,{props:{className:i},children:[this.icon?'<span class="ui-action-panel-item-icon"><img src="'+this.icon+'"></span>':null,this.text&&!this.buttonIconClass&&this.iconOnly!==true?'<span class="ui-action-panel-item-title">'+this.text+"</span>":this.iconOnly!==true?this.text:null],attrs:this.attributes,dataset:{role:"action-panel-item"},events:{click:this.handleClick.bind(this)}})}this.href?this.layout.container.setAttribute("href",this.href):null;this.href||this.title?this.layout.container.setAttribute("title",this.title?this.title:this.text):null;if(BX.type.isString(this.onclick)){this.layout.container.setAttribute("onclick",this.onclick)}if(this.dataset){BX.adjust(this.layout.container,{dataset:this.dataset})}if(this.options.hide){this.hide()}return this.layout.container},show:function(){BX.show(this.layout.container,"block")},showAsInlineBlock:function(){BX.style(this.layout.container,"display","inline-block")},hide:function(){BX.hide(this.layout.container,"none")},destroy:function(){BX.remove(this.layout.container)},isVisible:function(){if(this.layout.container.offsetTop>8){return false}return true},isNotFit:function(){return this.layout.container.offsetHeight>0&&!this.isVisible()},handleMenuClick:function(t){if(this.isDisabled()){t.preventDefault();return}return this.openSubMenu()},handleMainClick:function(t){if(this.isDisabled()){t.preventDefault();return}if(BX.type.isFunction(this.onclick)){this.onclick.call(this,t,this)}},handleClick:function(t){if(this.isDisabled()){t.preventDefault();return}if(BX.type.isArray(this.items)&&this.items.length>0){this.openSubMenu()}else{if(BX.type.isFunction(this.onclick)){this.onclick.call(this,t,this)}}},isDisabled:function(){return this.disabled},disable:function(){this.disabled=true;if(this.layout&&this.layout.container){BX.data(this.layout.container,"slider-ignore-autobinding",true);this.layout.container.classList.add("ui-action-panel-item-is-disabled")}},enable:function(){this.disabled=false;if(this.layout&&this.layout.container){BX.data(this.layout.container,"slider-ignore-autobinding",false);this.layout.container.classList.remove("ui-action-panel-item-is-disabled")}},openSubMenu:function(){if(!BX.type.isArray(this.items)||this.items.length===0){return}var t=this.layout.container;var i={className:"ui-action-panel-item-popup-menu",angle:true,zIndex:this.actionPanel.zIndex?this.actionPanel.zIndex+1:null,offsetLeft:t.offsetWidth/2,closeByEsc:true,events:{onPopupClose:function(){s.destroy();BX.removeClass(t,"ui-action-panel-item-active")}}};i=BX.mergeEx(i,this.submenuOptions);var s=BX.PopupMenu.create("ui-action-panel-item-popup-menu",t,this.items,i);s.layout.menuContainer.setAttribute("data-tile-grid","tile-grid-stop-close");s.show();BX.addClass(this.layout.container,"ui-action-panel-item-active")}}})();
//# sourceMappingURL=item.map.js